<?php
//error_reporting(0);
define('DS', DIRECTORY_SEPARATOR);
define('WEBROOT', dirname(__FILE__));
define('BASE', WEBROOT . DS . 'base');
define('CONTROLLER', WEBROOT . DS . 'controller');
define('VIEWER', WEBROOT . DS . 'viewer');

# 变量配置
define('HOME_URL', 'http://t.19lou.com/');

# 环境配置
$path = array();
$path[] = '.';
$path[] = WEBROOT;
app_set_include_path($path);

function app_set_include_path ($paths) {
    set_include_path(implode(PATH_SEPARATOR, $paths));
}

# 路由分发
require_once BASE . DS . 'Dispatch.php';
$query = (isset($_GET['q'])) ? $_GET['q'] : 'default';
$dispatch = Dispatch::getDispatch($query, CONTROLLER);
if ($dispatch == FALSE) {
    echo 'the path is not exist!';# 404错误或主页
    exit();
}
$dispatch->execute();
?>